'use strict';

module.exports = app => {
  const mongoose = app.mongoose;
  const Schema = mongoose.Schema;
  const ObjectId = Schema.ObjectId;

  const ChatMessageSchema = new Schema({
    expert_id: { type: ObjectId },
    chat_room_id: { type: ObjectId },
    from_user_id: { type: ObjectId },
    to_user_id: { type: ObjectId },
    self: { type: Boolean},
    message: { type: String},
    state: { type: String},
    create_at: { type: Date, default: Date.now },
    update_at: { type: Date, default: Date.now },
    deleted: { type: Boolean, default: false },
  });

  return mongoose.model('ChatMessage', ChatMessageSchema);
};
